﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using KOPLibrary.DataManagement.Cacheflow;

namespace KOPLibrary.Forms.CashFlow
{
    public partial class AccountsUc : KOPLibrary.Forms.CashFlow.CacheflowUserControlBase
    {
        public AccountsUc()
        {
            InitializeComponent();
        }

        private void hesapBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            Commit();

        }

        public override void Commit()
        {
            base.Commit();
            this.Validate();
            this.hesapBindingSource.EndEdit();
            DataLayer.SaveCachflowData(currentDataSource);
            //this.tableAdapterManager.HesapTableAdapter.Update(currentDataSource.Hesap);
        }



        internal void BindAsDetail(BindingSource source, string dataMember)
        {
            Bind(source.DataSource as Cacheflow.CacheflowDs);
            hesapBindingSource.DataSource = source;
            hesapBindingSource.DataMember = dataMember;
        }


        private void hesapDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void hesapDataGridView_CellContentClick()
        {

        }

        private void hesapBindingSource_AddingNew(object sender, AddingNewEventArgs e)
        {
            DataRowView rView = (hesapBindingSource.List as DataView).AddNew();
            rView.Row["ID"] = Guid.NewGuid();
            e.NewObject = rView;
        }

        private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
        {
            
        }

        private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
        {
            Commit();
        }

        private void hesapBindingNavigator_RefreshItems(object sender, EventArgs e)
        {

        }
    }
}
